package com.example.springboot.service.impl;

import com.example.springboot.controller.request.BaseRequest;
import com.example.springboot.entity.ReturnBook;
import com.example.springboot.mapper.ReturnBookMapper;
import com.example.springboot.service.IReturnBookService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class ReturnBookService implements IReturnBookService {

    @Resource
    ReturnBookMapper returnBookMapper;


    //查询所有
    @Override
    public List<ReturnBook> list() {
        return returnBookMapper.list();
    }

    //分页
    @Override
    public PageInfo<ReturnBook> page(BaseRequest baseRequest) {
        PageHelper.startPage(baseRequest.getPageNum(), baseRequest.getPageSize());

        List<ReturnBook> borrows = returnBookMapper.listByCondition(baseRequest);

        return new PageInfo<>(borrows);
    }


    //新增


    @Override
    public ReturnBook getById(Integer id) {
        return returnBookMapper.getById(id);
    }

    //删除
    @Override
    public void deleteById(Integer id) {
        returnBookMapper.deleteById(id);
    }

    @Override
    public ReturnBook getByIds(Integer id) {
        return returnBookMapper.getByIds(id);
    }
}
